package com.patterns.factory.NvWaFactory.factory;

import com.patterns.factory.NvWaFactory.human.Human;

/**
 * Created by Xiao Yiyun on 2017/6/28.
 * 具体工厂类
 */
public class Factory extends AbstractFactory {
    public <T extends Human> T creatHuman(Class<T> c) {
        //定义要生产的人种对象
        Human human = null;
        try {
            //产生一个人种
            human = (T)Class.forName(c.getName()).newInstance();
        } catch (Exception e) {
            System.out.println("人种产生错误");
        }
        return (T)human;
    }
}
